1. Technical Field of the Invention
The present invention relates generally to a bar code reader designed to determine the position and orientation of a bar code in a captured image of a document such as postal matter on which characters etc. are printed for decoding the bar code correctly.
2. Background Art
Bar codes are in widespread use as a means carrying information on management of articles in marketing, distribution, and production processes. Such bar codes are typically read out by a portable scanner such as a hand-held scanner and a pen-input scanner designed to scan a bar code directly by an operator or a stationary scanner designed to sweep a plurality of light beams in different directions to read a bar code through at least one of the light beams scanning the bar code correctly. A decoding system is also known which captures a two-dimensional image of a target object and extracts a bar code area from the image through image processing to decode a bar code. This system has the advantage of decoding a bar code correctly regardless of position and orientation of the bar code and even if a plurality of different bar codes are also printed on a target object. Japanese Patent First Publication No. 02-125386 teaches a bar code-reading system using a two-dimensional image which is shown in FIG. 17.
An image from an input device 901 is transformed into a binary data through a binary coding circuit 903. The binary data is transformed by an edge detector 904 into a bar contour image and inputted to a black expansion circuit 905. The black expansion circuit 905 fuses contours of bars of the bar code in the inputted image to produce a smeared bar code area in the image. A black contraction circuit 906 contracts black patterns smaller than a given size to delete characters etc. in the background of the inputted image and extracts the bar code area. A bar code axis determining circuit 907 defines a bar code axis line passing through the bar code area. A readout coordinate determining circuit 908 reads an image data out of an image memory 902 based on the bar code axis line. A decoder 909 decodes the bar code contained in the image data read out of the image memory 902 regardless of the position and orientation of the bar code in the image.
However, in a case of a bar code such as a Postnet bar code or an RM4SC (i.e., a 4-state code) made up of short bars substantially equal in length to that of characters printed near the bar code, a drawback is encountered in that the deletion of the patterns in the background of the image through the black contraction circuit 906 may cause the bar code area to be also deleted from the image. In order to avoid this problem, the degree to which the black patterns are shrunk may be decreased, but it may also lead to a problem that the characters are left in the background, thereby making it difficult to extract the bar code area only.
It is therefore a principal object of the present invention to avoid the disadvantages of the prior art.
It is another object of the present invention to provide a bar code reader designed to extract a bar code area from a background of a captured image correctly even if a bar code is made up of a relatively short bars such as a 4-state bar for decoding the bar code with high reliability.
According to one aspect of the invention, there is provided a bar code reader which comprises: (a) an image capturing device capturing an image containing a bar code; (b) a binary coding circuit transforming the image captured by the image capturing device into a binary image in which a background is expressed in a binary 0, and each pattern is expressed in a binary 1; (c) an image storage storing therein the binary image produced by the binary coding circuit; (d) a shrinking circuit shrinking each pattern in a binary image outputted from the binary coding circuit by k pixels (k is a positive integral number) from a background side; (e) a vertical expansion circuit expanding each pattern in a binary image outputted from the shrinking circuit vertically by m pixel (m is a positive integral number); (f) an edge detector detecting a contour of each pattern in a binary image outputted from the vertical expansion circuit to produce a binary image containing an edge of each pattern in the inputted binary image; (g) a horizontal expansion circuit expanding each pattern in the binary image outputted from the edge detector horizontally by n1 pixel (n1 is a positive integral number); (h) a horizontal contraction circuit contracting each pattern in a binary image outputted from the horizontal expansion circuit horizontally by n2 (n2 is a positive integral number); (i) an identification circuit labeling patterns in a binary image outputted from the horizontal contraction circuit to identify the patterns, the identification circuit specifying a bar code area based on shape characteristics of the patterns; and (j) a decoder selecting data on the binary image stored in the image storage which belongs in the bar code area specified by the identification circuit to decode the bar code in the image captured by the image capturing device.
In the preferred mode of the invention, the bar code reader may further includes (a) a horizontal expansion circuit expanding each pattern in the binary image outputted from the shrinking circuit horizontally by the m pixel, (b) an edge detector detecting a contour of each pattern in a binary image outputted from the horizontal expansion circuit to produce a binary image containing an edge of each pattern in the inputted binary image, (c) a vertical expansion circuit expanding each pattern in the binary image outputted from the edge detector vertically by the n1 pixel, (d) a vertical contraction circuit contracting each pattern in a binary image outputted from the vertical expansion circuit vertically by the n2, and (e) an OR circuit logically oring outputs from the horizontal contraction circuit and the vertical contraction circuit to provide an output to the identification circuit.
The identification circuit determines one of a size, a peripheral length, and a circumscribed rectangle of each pattern in the image outputted from the horizontal contraction circuit as a feature of each pattern and specifies the bar code area based on the features of the patterns.
The identification circuit may alternatively determines the feature of each pattern in the image inputted from one of the horizontal contraction circuit and the vertical contraction circuit through the OR circuit.
The bar code contained in the image captured by the image capturing device may be a four-state bar code made up of a combination of long bars, semilong bars, and timing bars. The identification circuit identifies each pattern in the binary image outputted from the horizontal contraction circuit as one of the long bar, the semilong bar, and the timing bar, determines a line passing through centers of the patterns identified as the semilong bar, determines whether a center of each of the patterns identified as the semilong bar lies on a firs side of the line or a second side opposed to the first side to find a positional relation between each of the patterns identified as the semilong bar and the line, and decodes the bar code using the positional relation.
The identification circuit may alternatively identify each pattern in the binary image inputted from one of the horizontal contraction circuit and the vertical contraction circuit through the OR circuit as one of the long bar, the semilong bar, and the timing bar.